<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>
    /*消耗品信息自动补全*/
    autoCompleteExp("expNameId");
    function autoCompleteExp(inputId){
        var url="${ctx}/csm/expDict/autoComplete?expCode=${expInfo.expDict.expCode}";
        autoComplete(inputId,url,
            function(data){
                var rows = [];
                for(var i=0; i<data.length; i++){
                    rows[rows.length] = {
                        data:data[i],
                        value:data[i].id,
                        result:data[i].expName
                    };
                }
                return rows;
            },function(data, i, max){
                if($.trim(data.expModel) != '' && null != data.expModel && typeof(data.expModel) != 'undefined'){
                    return data.expCode+"|"+data.expName+"|"+data.expSpec + '|' + data.expModel;
                }else{
                    return data.expCode+"|"+data.expName+"|"+data.expSpec;
                }
            },function(event,data,formatted){
                $('#expModel').attr('value',data.expModel);
                $('#expId').attr('value',data.id);
                $('#minSpec').attr('value',data.expSpec);
//                $('#minUnits').attr('value',data.units);
                $("#minUnits option[value='"+data.units+"']").attr("selected", true);
                $('#minUnits').change();
            });
    }

    /*消耗品厂商补全*/
    autoCompleteFirm("supplierName");
    function autoCompleteFirm(inputId){
        var url="${ctx}/csm/expSupplierCata/autoComplete?supplierClass=0";
        autoComplete(inputId,url,
            function(data){
                var rows = [];
                for(var i=0; i<data.length; i++){
                    rows[rows.length] = {
                        data:data[i],
                        value:data[i].id,
                        result:data[i].supplierName
                    };
                }
                return rows;
            },function(data, i, max){
                return data.inputCode+"|"+data.supplierName;
            },function(event,data,formatted){
                $('#expSupplierCataId').attr('value',data.id);
            });
    }

    function funPackSpec(numId,minId,specId){
        var num = $.trim($("#"+numId).val());
        var min = $.trim($("#"+minId).val());
        if (num!=1&&num!='1'){
            $("#"+specId).val(min+"*"+num);
        }else {
            $("#"+specId).val(min);
        }
    }

</script>
<div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li>
                    <a href="#"  onclick="loadDiv('rigthCenterDiv','${ctx}/csm/expInfo/index?expDict.expCode=${expInfo.expDict.expCode}')">消耗品基本信息列表</a>
                </li>
                <li class="active">
                    <a href="#" onclick="loadDiv('rigthCenterDiv','${ctx}/csm/expInfo/form?expDict.expCode=${expInfo.expDict.expCode}')">
                        <c:choose>
                            <c:when test="${expInfo.id==''|| expInfo.id==null}">
                                消耗品基本信息添加
                            </c:when>
                            <c:otherwise>消耗品基本信息修改</c:otherwise>
                        </c:choose>
                    </a>
                </li>
            </ul>
            <section class="panel panel-default">
                <div class="panel-body">
                    <div class="col-lg-12">
                        <form:form id="inputForm" data-parsley-validate="" modelAttribute="expInfo" onsubmit="return formSaveLoad('rigthCenterDiv','inputForm','${ctx}/csm/expInfo/save','${ctx}/csm/expInfo/index?expDict.expCode=${expInfo.expDict.expCode}');" method="post" class="form-horizontal">
                            <form:hidden path="id"/>
                            <form:hidden path="expDict.id" id="expId"/>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">消耗品名称：</label>
                                    <div class="col-sm-4">
                                        <form:input path="expDict.expName" id="expNameId" htmlEscape="false" class="form-control"  maxlength="64" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">消耗品代码：</label>
                                    <div class="col-sm-4">
                                        <form:input path="expDict.expCode" id="expCode" htmlEscape="false" class="form-control"  maxlength="64" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">型号：</label>
                                    <div class="col-sm-4">
                                        <form:input path="expDict.expModel" id="expModel" htmlEscape="false" class="form-control"  maxlength="64" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">包装数量：</label>
                                    <div class="col-sm-4">
                                        <form:input path="packageNum" id="packageNum" htmlEscape="false" class="form-control" data-parsley-required="true" data-parsley-type="number" maxlength="11" onblur="return funPackSpec('packageNum','minSpec','packageSpec')"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">包装规格：</label>
                                    <div class="col-sm-4">
                                        <form:input path="packageSpec" id="packageSpec" htmlEscape="false" readonly="true" data-parsley-required="true" class="form-control"  maxlength="20" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">包装单位：</label>
                                    <div class="col-sm-4">
                                        <form:select path="packageUnit" class="form-control" data-parsley-required="true">
                                            <form:option value="" label=""/>
                                            <form:options items="${fns:getDictList('SPEC_UNIT')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                        </form:select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">消耗品厂商：</label>
                                    <div class="col-sm-4">
                                        <form:hidden path="expSupplierCata.id" id="expSupplierCataId"/>
                                        <form:input path="expSupplierCata.supplierName" id="supplierName" htmlEscape="false" class="form-control"  maxlength="64" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">最小规格：</label>
                                    <div class="col-sm-4">
                                        <form:input path="minSpec" id="minSpec" htmlEscape="false" class="form-control" readonly="true" data-parsley-required="true" maxlength="20" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">最小单位：</label>
                                    <div class="col-sm-4">
                                        <form:select path="minUnits" id="minUnits" class="form-control" data-parsley-required="true" disabled="true">
                                            <form:option value="" label="" />
                                            <form:options items="${fns:getDictList('SPEC_UNIT')}" itemLabel="label" itemValue="value" htmlEscape="false" />
                                        </form:select>
                                    </div>
                                </div>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-2 control-label">批准文号：</label>--%>
                                    <%--<div class="col-sm-4">--%>
                                        <%--<form:input path="passNo" htmlEscape="false" class="form-control"  maxlength="30" />--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-2 control-label">产品编号：</label>--%>
                                    <%--<div class="col-sm-4">--%>
                                        <%--<form:input path="expItemNo" htmlEscape="false" class="form-control"  maxlength="30" />--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-2 control-label">外观专利号：</label>--%>
                                    <%--<div class="col-sm-4">--%>
                                        <%--<form:input path="exteriorPatentNo" htmlEscape="false" class="form-control"  maxlength="30" />--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-2 control-label">企业登记号：</label>--%>
                                    <%--<div class="col-sm-4">--%>
                                        <%--<form:input path="companyRegistNo" htmlEscape="false" class="form-control"  maxlength="30" />--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-2 control-label">生产备案号：</label>--%>
                                    <%--<div class="col-sm-4">--%>
                                        <%--<form:input path="produceRecordNo" htmlEscape="false" class="form-control"  maxlength="30" />--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-2 control-label">产品备案号：</label>--%>
                                    <%--<div class="col-sm-4">--%>
                                        <%--<form:input path="goodsRecordNo" htmlEscape="false" class="form-control"  maxlength="30" />--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-2 control-label">生产许可证号：</label>--%>
                                    <%--<div class="col-sm-4">--%>
                                        <%--<form:input path="produceLicenseNo" htmlEscape="false" class="form-control"  maxlength="30" />--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-2 control-label">卫生许可证号：</label>--%>
                                    <%--<div class="col-sm-4">--%>
                                        <%--<form:input path="hygienceLicenseNo" htmlEscape="false" class="form-control"  maxlength="30" />--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-2 control-label">产品技术要求编号：</label>--%>
                                    <%--<div class="col-sm-4">--%>
                                        <%--<form:input path="technologyRequireNo" htmlEscape="false" class="form-control"  maxlength="30" />--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">医疗器械注册证号：</label>
                                    <div class="col-sm-4">
                                        <form:input path="medicalDeviceRegistNo" htmlEscape="false" class="form-control"  maxlength="30" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">执行标准：</label>
                                    <div class="col-sm-4">
                                        <form:input path="executeStandardNo" htmlEscape="false" class="form-control"  maxlength="30" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">检测方法(试剂)：</label>
                                    <div class="col-sm-4">
                                        <form:input path="testMethod" htmlEscape="false" class="form-control"  maxlength="30" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">备注：</label>
                                    <div class="col-sm-4">
                                        <form:textarea path="remarks" htmlEscape="false" class="form-control"  maxlength="1000"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存">&nbsp;
                                        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="loadDiv('rigthCenterDiv','${ctx}/csm/expInfo/index?expDict.expCode=${expInfo.expDict.expCode}')">
                                </div>
                            </div>
                        </form:form>
                    </div>

                </div>
            </section>
        </div>
    </div>
<script>
    if("${expInfo.minUnits}"!=''){
        minUnitsName(${expInfo.minUnits});
    }
    function minUnitsName(minUnits){
        $('#minUnits').attr('value',minUnits);
        $("#minUnits option[value="+minUnits+"]").attr("selected", true);
        $('#minUnits').change();
    }
</script>